package com.are.inventario;

import java.util.ArrayList;
import java.util.List;


import android.app.AlertDialog;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends ListActivity {
    /** Called when the activity is first created. */
	private Toast toast;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.main);
        
        /* 
        TextView imei = (TextView)findViewById(R.id.imei);
        
        TelephonyManager tm = (TelephonyManager) getSystemService(this.TELEPHONY_SERVICE);
        String device_id = tm.getDeviceId();
        imei.setText("IMEI: " + device_id.toString() );
       */
        List<Lista> menu = new ArrayList<Lista>();
        menu.add(new Lista("Transformador", "Actualizar informacion del TRAFO"));
        menu.add(new Lista("Placas", "Actualizar informacion de placas del TRAFO"));
        menu.add(new Lista("Actualizar BDI", "Actualizacion de informacion BDI"));
        menu.add(new Lista("Actualizar Trafo-suministro", "Actualizacion de vinculo Trafo-Suministro"));
        menu.add(new Lista("Nuevo Trafo-suministro", "Nuevo vinculo Trafo-Suministro"));
        menu.add(new Lista("GPS", "Obtener informacion del GPS"));
        menu.add(new Lista("Terminar", "Salir de la Aplicacion"));
        
        
        AdaptadorTitulares adaptador =
                new AdaptadorTitulares(this,menu);
         
        
        setListAdapter(adaptador);
        //ListView lstOpciones = (ListView)findViewById(R.id.LstOpciones);
        
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub
        super.onListItemClick(l, v, position, id);
        Log.e("Are","Has seleccionado el elemento "+position);
        switch (position) {
        case 0:
        	startActivity(new Intent(this, TrafoActivity.class));
         break;
        case 1:

        	startActivity(new Intent(this, PlacaActivity.class));
        	//toast = Toast.makeText(getApplicationContext(), "En construccion", Toast.LENGTH_LONG);
			//toast.show();
        break;
        case 2:
        	startActivity(new Intent(this, ActualizarTrafoActivity.class));
        	break;
        case 3:
        	startActivity(new Intent(this, BuscarClienteActivity.class));
        	break;
        case 4:
        	//startActivity(new Intent(this, BuscarClienteActivity.class));
        	crearDialogoAlerta("En construccion").show();
        	break;
        case 5:
        	startActivity(new Intent(this, GPSActivity.class));
        	break;
        case 6:
        	System.exit(0);
        	break;
        
        
        }
    }
    
    private Dialog crearDialogoAlerta(String mensaje) {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("Informacion");
		builder.setMessage(mensaje);
		builder.setCancelable(false);
		builder.setPositiveButton("OK", new android.content.DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				// TODO Auto-generated method stub
				dialog.cancel();
			}
		});		
		return builder.create();
	}
    
    
}